﻿using System.Windows.Forms;
using System.Xml;
namespace zyconfig
{
    public class DbConfig
    {
        public static readonly string DataBaseName = GetXmlText("DataBaseName");
        public static readonly string DataBaseType = GetXmlText("DataBaseType");
        public static readonly string PassWord = GetXmlText("PassWord");
        public static readonly string ServerName = GetXmlText("ServerName");
        public static readonly string UserName = GetXmlText("UserName");
        public static readonly string Port = GetXmlText("Port");
        public static readonly string WorkDir = GetXmlText("WorkDir");
        public static readonly string DelOnUpLoadSucess = GetXmlText("DelOnUpLoadSucess");
        public static readonly string UpLoadFTP = GetXmlText("UpLoadFTP");
        public static readonly string FtpAddress = GetXmlText("FtpAddress");
        public static readonly string FtpPass = GetXmlText("FtpPassWord");
        public static readonly string FtpPort = GetXmlText("FtpPort");
        public static readonly string FtpUser = GetXmlText("FtpUserName");

        private static string GetXmlText(string NodeName)
        {
            string filename = Application.StartupPath + @"\Config\SysConfig.config";
            XmlDocument document = new XmlDocument();
            document.Load(filename);
            XmlNodeList childNodes = document.SelectSingleNode("configuration").ChildNodes;
            foreach (XmlNode node in childNodes)
            {
                if (node.Name == NodeName)
                {
                    return node.InnerText;
                }
            }
            return "";
        }

    }
}
